package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.dg11185.nearshop.net.entity.FavorItem;

public class MyFavorListResponse {
	
	public NetStatus status = null;
	
	public String total = null;
	
	public List<FavorItem> favorList = null;
	
	public MyFavorListResponse(){
		favorList = new ArrayList<FavorItem>() ;
	}
	
	public void parseJson(String response) throws JSONException {
		
		JSONObject jsonObject = new JSONObject(response);
        
        status = NetStatus.getStatus(jsonObject.optString("status"));
		
        total = jsonObject.optString("total");
        
        if (!jsonObject.isNull("favorList")){
        	
        	JSONArray array = jsonObject.getJSONArray("favorList");
        	
        	for (int i = 0; i < array.length(); i++) {
        		FavorItem favorItem = new FavorItem();
        		JSONObject object = array.getJSONObject(i);
        		favorItem.favorId = object.optString("favorId");
        		favorItem.favorTime = object.optString("favorTime");
        		favorItem.userId = object.optString("userId");
        		favorItem.merchantId = object.optString("merchantId");
        		favorItem.remark = object.optString("remark");
        		favorList.add(favorItem);
        	}
        	
        }
        
        
	}
	
	
}
